<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>快递公司管理</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/search.css">
</head>
<body style="overflow-x:hidden;background:#f3f3f3;">
    <div class="btn-div clearfix">
        <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#demoModal">添加公司</button>
        <div class="search-box">
            <form action="/expressCompany/findByKey" method="get" name="frm">
                <input  name="key" type="text" th:value="${key}" placeholder="请输入公司名称">
                <input name="currPage" type="hidden" id="currPage"/>
                <button type="submit"  class="btn btn-success">搜索</button>
            </form>
        </div>
    </div>
    <div>
        <table class="table table-condensed">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>快递公司</th>
                    <th>联系方式</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            <!--/*@thymesVar id="page" type="com.github.pagehelper.PageInfo;"*/-->
                <tr th:each="obj,i:${page.getList()}">
                    <td th:text="${i.count}"></td>
                    <td id="expressCompanyName" th:text="${obj.expressCompanyName}"></td>
                    <td id="contactWay" th:text="${obj.contactWay}"></td>
                    <td>
                        <a type="button" class="btn btn-default btn-xs" th:href="@{/expressCompany/Delete(expressCompanyName=${obj.expressCompanyName})}">删除</a>
                        <a type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#demoModal1"
                           th:onclick="|getData(${obj.id})|">修改
                        </a>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
    <!-- 弹出框 -->
    <!--新增弹出框-->
    <div class="modal fade" id="demoModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">添加公司</h4>
                </div>
                <form action="/expressCompany/Add" method="get" class="form-horizontal add">
                    <div class="modal-body">
                            <div class="form-group ">
                                <label for="firstname" class="col-sm-2 control-label">公司名称</label>
                                <div class="col-sm-10">
                                    <input onblur="checkName1();checkSave1()" type="text" name="firstname" class="form-control" id="firstname" placeholder="请输入公司名称">
                                    <span id="name" class="notice"></span>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="secondname" class="col-sm-2 control-label">公司联系方式</label>
                                <div class="col-sm-10">
                                    <input onblur="checkPhone1();checkSave1()" type="text" name="secondname" class="form-control" id="secondname" placeholder="请输入公司联系方式">
                                    <span id="contactWay1" class="notice"></span>
                                </div>
                            </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" onclick="clean()">取消</button>
                        <button onclick="add()" type="button" class="btn btn-primary save"  data-dismiss="modal" id="save1">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- 修改 -->
    <div class="modal fade" id="demoModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel1">修改公司信息</h4>
                </div>
                <form action="/expressCompany/Add" method="get" class="form-horizontal add">
                    <div class="modal-body">
                        <div class="form-group" >
                            <label for="firstname" class="col-sm-2 control-label">公司名称</label>
                            <input id="key" name="key" style="display:none">
                            <div class="col-sm-10">
                                <input onblur="checkName();checkSave()" type="text" name="firstname2" class="form-control" id="firstname2" placeholder="请输入公司名称">
                                <span id="name2" class="notice"></span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="secondname" class="col-sm-2 control-label">公司联系方式</label>
                        <div class="col-sm-10">
                            <input onblur="checkPhone();checkSave()" type="text" name="secondname2" class="form-control" id="secondname2" placeholder="请输入公司联系方式">
                            <span id="contactWay2" class="notice"></span>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" onclick="clean()">取消</button>
                        <button onclick="update()" type="button" class="btn btn-primary save"  data-dismiss="modal" id="save">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="footer-pager">
        <span>共<span th:text="${page.pages}"></span>页，当前第<span th:text="${page.pageNum}"></span>页</span>
        <ul class="pagination">
            <li>
                <a th:href="'javascript:go('+${page.pageNum+(-1)}+');'">&laquo;</a>
            </li>
            <li><a th:if="${page.pageNum}>1" th:href="'javascript:go('+${page.pageNum+(-1)}+');'"
                   th:text="${page.pageNum}-1"></a></li>
            <li class="active"><a th:href="'javascript:go('+${page.pageNum}+');'" th:text="${page.pageNum}"></a></li>
            <li><a th:if="${page.pageNum+1}<=${page.pages}" th:href="'javascript:go('+${page.pageNum+1}+');'"
                   th:text="${page.pageNum+1}"></a></li>
            <li th:if="${page.pageNum}==1"><a th:if="${page.pageNum+2}<=${page.pages}"
                                              th:href="'javascript:go('+${page.pageNum+1}+');'"
                                              th:text="${page.pageNum+2}"></a></li>
            <li><a th:href="'javascript:go('+${page.pageNum+1}+');'">
                &raquo;</a>
            </li>
        </ul>
    </div>
</body>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="/js/expressCompany/add-update.js"></script>
</html>